//
//  XMN_ProgressHUD.m
//  XMN_ProgressHUD
//
//  Created by dllo on 15/11/12.
//  Copyright © 2015年 谢美娜. All rights reserved.
//

#import "XMN_ProgressHUD.h"
#import "Header.h"

@implementation XMN_ProgressHUD

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _XMN_backView = [[UIView alloc]initWithFrame:CGRectMake((self.frame.size.width - 150 * FitWidth) / 2.0, (self.frame.size.height - 170 * FitHeight) / 2.0, 150 * FitWidth, 100 * FitHeight)];
        _XMN_backView.layer.masksToBounds = YES;
        _XMN_backView.layer.cornerRadius = 10;
        [_XMN_backView NightWithType:UIViewColorType1];
        _XMN_backView.alpha = .8;
        [self addSubview:_XMN_backView];
        
        _XMN_imageView = [[UIImageView alloc]initWithFrame:CGRectMake((_XMN_backView.frame.size.width - 50 * FitWidth) / 2.0, 10 * FitHeight, 50 * FitWidth, 50 * FitHeight)];
        [_XMN_backView addSubview:_XMN_imageView];
        
        _XMN_label = [[UILabel alloc]initWithFrame:CGRectMake(0, 60 * FitHeight, _XMN_backView.frame.size.width, 30 * FitHeight)];
        _XMN_label.textColor = [UIColor whiteColor];
        _XMN_label.textAlignment = 1;
        [_XMN_backView addSubview:_XMN_label];
        
        _XMN_imageArray = [NSMutableArray array];
    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    for (NSInteger i = 1; i < 11; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%ld", i]];
        [_XMN_imageArray addObject:image];
    }
    _XMN_imageView.animationImages = _XMN_imageArray;
    _XMN_imageView.animationDuration = 1.5;
    _XMN_imageView.animationRepeatCount = 100000;
    [_XMN_imageView startAnimating];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
